#ifndef COURSE_PUB_H
#define COURSE_PUB_H

#define MAX_COURSE_NAME_LEN 50
#define MAX_COURSE_TYPE_LEN 20
#define MAX_STUDENTS 100

#include "student_pub.h"

// 课程结构体
typedef struct {
    char id[20];                    // 课程编号
    char name[MAX_COURSE_NAME_LEN]; // 课程名称
    char type[MAX_COURSE_TYPE_LEN]; // 课程性质
    int hours;                      // 授课学时
    float credits;                  // 学分
    char selected_students[MAX_STUDENTS][20]; // 选课学生列表
    int student_count;              // 已选人数
    int max_students;               // 人数上限
} Course;

// 课程链表节点
typedef struct CourseNode {
    Course course;
    struct CourseNode* next;
} CourseNode;

// 课程链表
typedef struct {
    CourseNode* head;
    int count;
} CourseList;

// 公共接口函数声明
CourseList* create_course_list();
void free_course_list(CourseList* list);
int add_course(CourseList* list, const char* id, const char* name, 
               const char* type, int hours, float credits, int max_students);
int delete_course(CourseList* list, const char* id);
Course* find_course(CourseList* list, const char* id);
int update_course(CourseList* list, const char* id, const char* new_name, 
                 const char* new_type, int new_hours, float new_credits, 
                 int new_max_students);
void display_all_courses(CourseList* list);
void course_management_menu(CourseList* list);
void course_selection_menu(StudentList* student_list, CourseList* course_list);
int enroll_student_in_course(CourseList* course_list, const char* course_id, 
                            const char* student_id);
int withdraw_student_from_course(CourseList* course_list, const char* course_id, 
                                const char* student_id);

#endif
